package com.tjec.framework.web.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.tjec.project.businessWorkbench.domain.*;
import com.tjec.project.businessWorkbench.dto.BmsAttachmentDto;
import com.tjec.project.system.domain.BmsAttachment;
import com.tjec.project.system.domain.BmsMdBusinessCategory;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class TreeSelectProjectDoc implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private String guid;

    /** 节点名称 */
    private String label;

    /** 顺序 **/
    private double sort;

    /** 文件夹权限标识 **/
    private String flag;

    /** 文件数量 **/
    private Integer counts;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectProjectDoc> children;

//    private List<BmsAttachment> attachments;

//    public List<BmsAttachment> getAttachments() {
//        return attachments;
//    }
//
//    public void setAttachments(List<BmsAttachment> attachments) {
//        this.attachments = attachments;
//    }

    public TreeSelectProjectDoc()
    {

    }

    public TreeSelectProjectDoc(BmsMdBusinessCategory businessCategory)
    {
        this.guid = businessCategory.getGuid();
        this.label = businessCategory.getMenuName();
        this.children = businessCategory.getChildren().stream().map(TreeSelectProjectDoc::new).collect(Collectors.toList());
    }

    public TreeSelectProjectDoc(BmsBusinessPickup bmsBusinessPickup)
    {
        this.guid = bmsBusinessPickup.getGuid();
        this.label = bmsBusinessPickup.getName();
        this.counts = bmsBusinessPickup.getCounts();
        this.children = new ArrayList<>();
    }

    public TreeSelectProjectDoc(BmsBusinessTask bmsBusinessTask)
    {
        this.guid = bmsBusinessTask.getGuid();
        this.label = bmsBusinessTask.getName();
        this.children = bmsBusinessTask.getChildren().stream().map(TreeSelectProjectDoc::new).collect(Collectors.toList());
    }

    public TreeSelectProjectDoc(BmsProjectDoc bmsProjectDoc)
    {
        this.guid = bmsProjectDoc.getGuid();
        this.label = bmsProjectDoc.getName();
        this.counts = bmsProjectDoc.getCounts();
//        this.children = bmsProjectDoc.getChildren().stream().map(TreeSelectProjectDoc::new).collect(Collectors.toList());
    }

    public TreeSelectProjectDoc(BmsBusinessDocArchive bmsBusinessDocArchive)
    {
        this.guid = bmsBusinessDocArchive.getGuid();
        this.label = bmsBusinessDocArchive.getName();
        this.counts = bmsBusinessDocArchive.getCounts();
//        this.children = bmsBusinessDocArchive.getChildren().stream().map(TreeSelectProjectDoc::new).collect(Collectors.toList());
    }

    public TreeSelectProjectDoc(BmsProjectDocCatalog bmsProjectDocCatalog)
    {
        this.guid = bmsProjectDocCatalog.getGuid();
        this.label = bmsProjectDocCatalog.getName();
        this.sort = bmsProjectDocCatalog.getSort();
        this.flag = bmsProjectDocCatalog.getIsEdit();
        this.counts = bmsProjectDocCatalog.getCounts();
        this.children = bmsProjectDocCatalog.getChildren().stream().map(TreeSelectProjectDoc::new).collect(Collectors.toList());
    }

    public String getGuid()
    {
        return guid;
    }

    public void setId(String guid)
    {
        this.guid = guid;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public List<TreeSelectProjectDoc> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelectProjectDoc> children)
    {
        this.children = children;
    }

    public double getSort() {
        return sort;
    }

    public void setSort(double sort) {
        this.sort = sort;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public Integer getCounts() {
        return counts;
    }

    public void setCounts(Integer counts) {
        this.counts = counts;
    }
}
